home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Complementary Applications 2004 February / SGI IRIX 6.5 Complementary Applications 2004 February.iso / dist / cde.idb / usr / dt / share / include / Xm / TextOutP.h.z / TextOutP.h
Encoding:
C/C++ Source or Header  |  2003-11-18  |  14.9 KB  |  473 lines

  1. /*
  2.  * TextOutP.h
  3.  *
  4.  * Copyright 2000, Silicon Graphics, Inc.
  5.  * ALL RIGHTS RESERVED
  6.  * 
  7.  * UNPUBLISHED -- Rights reserved under the copyright laws of the United
  8.  * States.   Use of a copyright notice is precautionary only and does not
  9.  * imply publication or disclosure.
  10.  *
  11.  * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
  12.  * Use, duplication or disclosure by the Government is subject to restrictions
  13.  * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
  14.  * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
  15.  * in similar or successor clauses in the FAR, or the DOD or NASA FAR
  16.  * Supplement.  Contractor/manufacturer is Silicon Graphics, Inc.,
  17.  * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
  18.  *
  19.  * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
  20.  * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
  21.  * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
  22.  * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
  23.  * GRAPHICS, INC.
  24.  */
  25. /* 
  26.  * @OSF_COPYRIGHT@
  27.  * (c) Copyright 1990, 1991, 1992, 1993, 1994 OPEN SOFTWARE FOUNDATION, INC.
  28.  * ALL RIGHTS RESERVED
  29.  *  
  30. */ 
  31. /*
  32.  * HISTORY
  33.  * Motif Release 1.2.5
  34. */
  35. /*   $XConsortium: TextOutP.h /main/cde1_maint/2 1995/08/18 19:28:06 drk $ */
  36. /*
  37. *  (c) Copyright 1989, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
  38. /*
  39. *  (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 HEWLETT-PACKARD COMPANY */
  40. #ifndef _XmTextOutP_h
  41. #define _XmTextOutP_h
  42.  
  43. #include <Xm/XmP.h>
  44. #include <Xm/Text.h>
  45.  
  46. #ifdef __cplusplus
  47. extern "C" {
  48. #endif
  49.  
  50. /****************************************************************
  51.  *
  52.  * Definitions for modules implementing and using text output routines.
  53.  *
  54.  ****************************************************************/
  55.  
  56. #define ShouldWordWrap(data, widget)    (data->wordwrap && \
  57.        (!(data->scrollhorizontal && \
  58.        (XtClass(widget->core.parent) == xmScrolledWindowWidgetClass))) \
  59.        && widget->text.edit_mode != XmSINGLE_LINE_EDIT && !data->resizewidth)
  60.  
  61. typedef struct _LineTableExtraRec {
  62.     Dimension width;
  63.     Boolean wrappedbychar;
  64. } LineTableExtraRec, *LineTableExtra ;
  65.  
  66. /*         
  67.  * output.c  (part of stext)
  68.  */
  69.  
  70. typedef unsigned int LineNum;
  71. typedef enum {on, off} OnOrOff;    /* For when Booleans aren't obvious enough. */
  72.  
  73. /*
  74.  * Return the line number containing the given position.  If text currently
  75.  * knows of no line containing that position, returns NOLINE.
  76.  */
  77.  
  78. #define NOLINE    30000
  79.  
  80. /*
  81.  * These next define the types of the routines that output is required
  82.  * to export for use by text and by input.
  83.  */
  84.  
  85. typedef struct _OutputDataRec {
  86.     XmFontList fontlist;    /* Fontlist for text. */
  87.     unsigned int blinkrate;
  88.     Boolean wordwrap;        /* Whether to wordwrap. */
  89.     Boolean cursor_position_visible;
  90.     Boolean autoshowinsertpoint;
  91.     Boolean hasfocus;
  92.     Boolean has_rect;
  93.     Boolean handlingexposures;    /* TRUE if in the midst of expose events. */
  94.     Boolean exposevscroll;    /* Non-zero if we expect expose events to be
  95.                    off vertically. */
  96.     Boolean exposehscroll;    /* Non-zero if we expect expose events to be
  97.                    off horizontally. */
  98.     Boolean resizewidth, resizeheight;
  99.     Boolean scrollvertical, scrollhorizontal;
  100.     Boolean scrollleftside, scrolltopside;
  101.     Boolean ignorevbar;        /* Whether to ignore callbacks from vbar. */
  102.     Boolean ignorehbar;        /* Whether to ignore callbacks from hbar. */
  103.     short int cursor_on;        /* Whether IBeam cursor is visible. */
  104.     Boolean refresh_ibeam_off;    /* Indicates whether area under IBeam needs
  105.                  * to be re-captured */
  106.     Boolean suspend_hoffset;    /* temporarily suspend horizontal scrolling */
  107.     Boolean use_fontset;        /* True if font to be used is fontset (and
  108.                  * thus need X11R5 Xmb* routines to draw */
  109.     Boolean have_inverted_image_gc; /* fg/bg of image gc have been swapped;
  110.                      * on == True, off == False */
  111.     OnOrOff blinkstate;
  112.     Position insertx, inserty;
  113.     int number_lines;        /* Number of lines that fit in the window. */
  114.     int leftmargin, rightmargin;
  115.     int topmargin, bottommargin;
  116.     int scrollwidth;        /* Total width of text we have to display. */
  117.     int vsliderSize;        /* How big the thumb is in the vbar. */
  118.     int hoffset;        /* How much we've scrolled off the left. */
  119.     int averagecharwidth;    /* Number of pixels for an "average" char. */
  120.     int tabwidth;        /* Number of pixels for a tab. */
  121.     short columns, rows;
  122.     Dimension lineheight;    /* Number of pixels per line. */
  123.     Dimension minwidth, minheight;
  124.     Dimension prevW;
  125.     Dimension prevH;
  126.     Dimension cursorwidth, cursorheight;
  127.     Dimension font_ascent;      /* ascent of the font[set] */
  128.     Dimension font_descent;     /* descent of the font[set] */
  129.     XtIntervalId timerid;
  130.     Pixmap cursor;        /* Pixmap for IBeam cursor stencil. */
  131.     Pixmap add_mode_cursor;    /* Pixmap to use for add mode cursor. */
  132.     Pixmap ibeam_off;        /* Pixmap for area under the IBeam. */
  133.     Pixmap stipple_tile;    /* stiiple for add mode cursor. */
  134.     GC gc, imagegc;
  135.     Widget vbar, hbar;
  136.     XFontStruct *font;        /* font used when NULL font is set. */
  137. /* New for 1.2 */
  138.     GC save_gc;                 /* GC for saving/resotring under IBeam */
  139.     short columns_set, rows_set; /* history of previously set dimensions */
  140. } OutputDataRec, *OutputData;
  141.  
  142.  
  143. /*
  144.  * Create a new instance of an output object.  This is expected to fill in
  145.  * info about innerwidget and output in the widget record.
  146.  */
  147.  
  148. #ifdef _NO_PROTO
  149. typedef void (*OutputCreateProc)();
  150. #else
  151. typedef void (*OutputCreateProc)(
  152.             Widget,
  153.             ArgList,
  154.             Cardinal) ;
  155. #endif
  156. /*
  157.  * Given an (x,y) coordinate, return the closest corresponding position. (For
  158.  * use by input; text shouldn't ever need to know.)
  159.  */
  160.  
  161. #ifdef _NO_PROTO
  162. typedef XmTextPosition (*XYToPosProc)(); /* ctx, x, y */
  163. #else
  164. typedef XmTextPosition (*XYToPosProc)(
  165.             XmTextWidget,
  166. #if NeedWidePrototypes
  167.             int,
  168.             int) ;
  169. #else
  170.             Position,    /* These are relative to the */
  171.             Position) ;    /* innerwindow returned above. */
  172. #endif
  173. #endif
  174.  
  175. /*
  176.  * Return the (x,y) coordinate corresponing to the given position.  If this
  177.  * returns FALSE, then the given position isn't being displayed.
  178.  */
  179.  
  180. #ifdef _NO_PROTO
  181. typedef Boolean (*PosToXYProc)(); /* widget, position, x, y */
  182. #else
  183. typedef Boolean (*PosToXYProc)(
  184.             XmTextWidget,
  185.             XmTextPosition,
  186.             Position *,    /* These are relative to the */
  187.             Position *) ;    /* innerwindow returned above. */
  188. #endif
  189.  
  190. /*
  191.  * Measures the extent of a line.  Given the line number and starting position
  192.  * of a line, returns the starting position of the next line.  Also returns
  193.  * any extra information that the output module may want to associate with
  194.  * this line for future reference.  (In particular, it will want to associate
  195.  * a vertical coordinate for this line.)  This routine should return FALSE if
  196.  * it decides that this line will not fit in the window.  FALSE should never
  197.  * be returned if the line number is zero.  Output may assume that the line
  198.  * table for all preceeding lines have already been set.  In particular, when
  199.  * this routine will return FALSE, then output knows that the entire linetable
  200.  * has been calculated; that is a good time for it to look over the linetable
  201.  * and decide if it wants to do something obnoxious like resize the window.
  202.  *
  203.  * A possible value to put in nextpos is PASTENDPOS.  This indicates that the
  204.  * current line contains the end of the text in the source.
  205.  *
  206.  * nextpos may be NULL.  If it is, then this indicates that we only want to
  207.  * know if the line will fit on the window.  The caller already has its own
  208.  * idea where the next line will start if it does fit.  (If nextpos is NULL,
  209.  * then no extra information should be generated, and the 'extra' parameter
  210.  * should be ignored.)
  211.  */
  212.  
  213. #define PASTENDPOS    2147483647  /* Biggest number that can fit in long */
  214.  
  215. #ifdef _NO_PROTO
  216. typedef Boolean (*MeasureLineProc)(); /* ctx, line, pos, nextpos, extra */
  217. #else
  218. typedef Boolean (*MeasureLineProc)(
  219.             XmTextWidget,
  220.             LineNum,
  221.             XmTextPosition,
  222.             XmTextPosition *,
  223.             LineTableExtraRec **) ;
  224. #endif
  225.  
  226. /*
  227.  * Draw some text within a line.  The output finds out information about the
  228.  * line by calling the line table routines.
  229.  *
  230.  * %%% Document special cases (like lines containing PASTENDPOS).
  231.  */
  232.  
  233. #ifdef _NO_PROTO
  234. typedef void (*DrawProc)();    /* ctx, line, start, end, highlight */
  235. #else
  236. typedef void (*DrawProc)(
  237.             XmTextWidget,
  238.             LineNum,
  239.             XmTextPosition,
  240.             XmTextPosition,
  241.             XmHighlightMode) ;
  242. #endif
  243.  
  244. /*
  245.  * Output should draw or erase an insertion point at the given position.
  246.  */
  247.  
  248. #ifdef _NO_PROTO
  249. typedef void (*DrawInsertionPointProc)(); /* ctx, position, onoroff */
  250. #else
  251. typedef void (*DrawInsertionPointProc)(
  252.             XmTextWidget,
  253.             XmTextPosition,
  254.             OnOrOff) ;
  255. #endif
  256.  
  257. /*
  258.  * Output should ensure that the given position is visible (e.g., not scrolled
  259.  * off horizontally).
  260.  */
  261. #ifdef _NO_PROTO
  262. typedef void (*MakePositionVisibleProc)();    /* widget, position */
  263. #else
  264. typedef void (*MakePositionVisibleProc)(
  265.             XmTextWidget,
  266.             XmTextPosition) ;
  267. #endif
  268.  
  269. /* Text would like to move some lines around on the screen.  It would like to
  270.  * move lines fromline through toline (inclusive) to now start at line
  271.  * destline.  If output can perform this move by means of a XCopyArea or
  272.  * similar simple call, it does so and returns TRUE; otherwise, it will return
  273.  * FALSE.  If TRUE, output should modify affected values in the
  274.  * "extra" entries in the linetable, because after returning text will go ahead
  275.  * and move linetable entries around.
  276.  */
  277.  
  278. #ifdef _NO_PROTO
  279. typedef Boolean (*MoveLinesProc)(); /* ctx, fromline, toline, destline */
  280. #else
  281. typedef Boolean (*MoveLinesProc)(
  282.             XmTextWidget,
  283.             LineNum,
  284.             LineNum,
  285.             LineNum) ;
  286. #endif
  287.  
  288. /*
  289.  * Inform output of invalidated positions.
  290.  */
  291.  
  292. #ifdef _NO_PROTO
  293. typedef void (*InvalidateProc)(); /* ctx, position, topos, delta */
  294. #else
  295. typedef void (*InvalidateProc)(
  296.             XmTextWidget,
  297.             XmTextPosition,
  298.             XmTextPosition,
  299.             long) ;
  300. #endif
  301.  
  302. /*
  303.  * Get preferred size of text widget based on the row and column
  304.  * resources multiplied by font attributes as well as adding the
  305.  * margin resource values to the computed size.
  306.  */
  307. #ifdef _NO_PROTO
  308. typedef void (*GetPreferredSizeProc)(); /* widget, width, height */
  309. #else
  310. typedef void (*GetPreferredSizeProc)(
  311.             Widget,
  312.             Dimension *,
  313.             Dimension *) ;
  314. #endif
  315.  
  316. /*
  317.  * Get values out of the output object.
  318.  */
  319.  
  320. #ifdef _NO_PROTO
  321. typedef void (*GetValuesProc)(); /* widget, args, num_args */
  322. #else
  323. typedef void (*GetValuesProc)(
  324.             Widget,
  325.             ArgList,
  326.             Cardinal) ;
  327. #endif
  328.  
  329. /*
  330.  * Set values in the output object.
  331.  */
  332.  
  333. #ifdef _NO_PROTO
  334. typedef Boolean (*SetValuesProc)(); /* oldw, reqw, new_w, args, num_args */
  335. #else
  336. typedef Boolean (*SetValuesProc)(
  337.             Widget,
  338.             Widget,
  339.             Widget,
  340.             ArgList,
  341.             Cardinal *) ;
  342. #endif
  343.  
  344.  
  345. typedef struct _OutputRec {
  346.     struct _OutputDataRec    *data; /* Output-specific data; opaque type. */
  347.     XYToPosProc            XYToPos;
  348.     PosToXYProc            PosToXY;
  349.     MeasureLineProc        MeasureLine;
  350.     DrawProc            Draw;
  351.     DrawInsertionPointProc    DrawInsertionPoint;
  352.     MakePositionVisibleProc    MakePositionVisible;
  353.     MoveLinesProc        MoveLines;
  354.     InvalidateProc        Invalidate;
  355.     GetPreferredSizeProc    GetPreferredSize;
  356.     GetValuesProc        GetValues;
  357.     SetValuesProc        SetValues;
  358.     XmRealizeOutProc        realize;
  359.     XtWidgetProc        destroy;
  360.     XmResizeFlagProc        resize;
  361.     XtExposeProc        expose;
  362. } OutputRec;
  363.  
  364.  
  365. /********    Private Function Declarations    ********/
  366. #ifdef _NO_PROTO
  367.  
  368. extern void _XmTextFreeContextData() ;
  369. extern void _XmTextResetClipOrigin() ;
  370. extern void _XmTextAdjustGC() ;
  371. extern Boolean _XmTextShouldWordWrap() ;
  372. extern Boolean _XmTextScrollable() ;
  373. extern XmTextPosition _XmTextFindLineEnd() ;
  374. extern void _XmTextOutputGetSecResData() ;
  375. extern int _XmTextGetNumberLines() ;
  376. extern void _XmTextMovingCursorPosition() ;
  377. extern void _XmTextDrawDestination() ;
  378. extern void _XmTextClearDestination() ;
  379. extern void _XmTextDestinationVisible() ;
  380. extern void _XmTextChangeBlinkBehavior() ;
  381. extern void _XmTextOutputCreate() ;
  382. extern Boolean _XmTextGetBaselines() ;
  383. extern Boolean _XmTextGetDisplayRect() ;
  384. extern void _XmTextMarginsProc() ;
  385. extern void _XmTextChangeHOffset() ;
  386. extern void _XmTextToggleCursorGC() ;
  387.  
  388. #else
  389.  
  390. extern void _XmTextFreeContextData( 
  391.                         Widget w,
  392.                         XtPointer clientData,
  393.                         XtPointer callData) ;
  394. extern void _XmTextResetClipOrigin( 
  395.                         XmTextWidget tw,
  396.                         XmTextPosition position,
  397. #if NeedWidePrototypes
  398.                         int clip_mask_reset) ;
  399. #else
  400.                         Boolean clip_mask_reset) ;
  401. #endif /* NeedWidePrototypes */
  402. extern void _XmTextAdjustGC( 
  403.                         XmTextWidget tw) ;
  404. extern Boolean _XmTextShouldWordWrap( 
  405.                         XmTextWidget widget) ;
  406. extern Boolean _XmTextScrollable( 
  407.                         XmTextWidget widget) ;
  408. extern XmTextPosition _XmTextFindLineEnd( 
  409.                         XmTextWidget widget,
  410.                         XmTextPosition position,
  411.                         LineTableExtra *extra) ;
  412. extern void _XmTextOutputGetSecResData( 
  413.                         XmSecondaryResourceData *secResDataRtn) ;
  414. extern int _XmTextGetNumberLines( 
  415.                         XmTextWidget widget) ;
  416. extern void _XmTextMovingCursorPosition( 
  417.                         XmTextWidget tw,
  418.                         XmTextPosition position) ;
  419. extern void _XmTextDrawDestination( 
  420.                         XmTextWidget widget) ;
  421. extern void _XmTextClearDestination( 
  422.                         XmTextWidget widget,
  423. #if NeedWidePrototypes
  424.                         int ignore_sens) ;
  425. #else
  426.                         Boolean ignore_sens) ;
  427. #endif /* NeedWidePrototypes */
  428. extern void _XmTextDestinationVisible( 
  429.                         Widget w,
  430. #if NeedWidePrototypes
  431.                         int turn_on) ;
  432. #else
  433.                         Boolean turn_on) ;
  434. #endif /* NeedWidePrototypes */
  435. extern void _XmTextChangeBlinkBehavior( 
  436.                         XmTextWidget widget,
  437. #if NeedWidePrototypes
  438.                         int newvalue) ;
  439. #else
  440.                         Boolean newvalue) ;
  441. #endif /* NeedWidePrototypes */
  442. extern void _XmTextOutputCreate( 
  443.                         Widget wid,
  444.                         ArgList args,
  445.                         Cardinal num_args) ;
  446. extern Boolean _XmTextGetBaselines( 
  447.                         Widget widget,
  448.                         Dimension **baselines,
  449.                         int *line_count) ;
  450. extern Boolean _XmTextGetDisplayRect( 
  451.                         Widget w,
  452.                         XRectangle *display_rect) ;
  453. extern void _XmTextMarginsProc( 
  454.                         Widget w,
  455.                         XmBaselineMargins *margins_rec) ;
  456. extern void _XmTextChangeHOffset( 
  457.                         XmTextWidget widget,
  458.                         int length) ;
  459. extern void _XmTextToggleCursorGC( 
  460.                         Widget widget) ;
  461.  
  462. #endif /* _NO_PROTO */
  463. /********    End Private Function Declarations    ********/
  464.  
  465.  
  466.  
  467. #if defined(__cplusplus) || defined(c_plusplus)
  468. }  /* Close scope of 'extern "C"' declaration which encloses file. */
  469. #endif
  470.  
  471. #endif /* _XmTextOutP_h */
  472. /* DON'T ADD ANYTHING AFTER THIS #endif */
  473.